//
//  DNTimeConsumeManagerTests.m
//  DanoneEA
//
//  Created by Senela on 16/11/2.
//  Copyright © 2016年 翔傲科技. All rights reserved.
//

#import <XCTest/XCTest.h>
#import "DNTimeConsumeDao.h"
#import "NSDate+Utils.h"

@interface DNTimeConsumeManagerTests : XCTestCase
{
    NSString *dateStr;
    NSString *dateStr1;
}
@end

@implementation DNTimeConsumeManagerTests

- (void)setUp {
    [super setUp];
    // Put setup code here. This method is called before the invocation of each test method in the class.
    
    dateStr = [NSDate currentTimeString];
    dateStr1 = @"2016-11-03";
     
}

- (void)tearDown {
    // Put teardown code here. This method is called after the invocation of each test method in the class.
    [super tearDown];
}

- (void)testExample {
    // This is an example of a functional test case.
    // Use XCTAssert and related functions to verify your tests produce the correct results.
}

- (void)testPerformanceExample {
    // This is an example of a performance test case.
    [self measureBlock:^{
        // Put the code you want to measure the time of here.
    }];
}

-(void)test1ForAddTime
{
    BOOL ret =[[DNTimeConsumeDao shareInstance] clearTimeByDate:dateStr];
    XCTAssertEqual(ret, YES, @"DNTimeConsumeDao-- clearTimeByDate error");
    
    ret = [[DNTimeConsumeDao shareInstance] appendTime:10 byType:ModuleType_Crying dateStr:dateStr];
    XCTAssertEqual(ret, YES, @"DNTimeConsumeDao-- addTime error");
    
    NSString *totalTime = [[DNTimeConsumeDao shareInstance] getTimeByDate:dateStr type:ModuleType_Crying];
    XCTAssertEqual(totalTime.integerValue, 10, @"DNTimeConsumeDao-- getTimeByDate error");
}

-(void)test2ForAppendTime
{
    bool ret = [[DNTimeConsumeDao shareInstance] appendTime:10 byType:ModuleType_Crying dateStr:dateStr];
    XCTAssertEqual(ret, YES, @"DNTimeConsumeDao-- appendTime error");
    
    NSString *totalTime = [[DNTimeConsumeDao shareInstance] getTimeByDate:dateStr type:ModuleType_Crying];
    XCTAssertEqual(totalTime.integerValue, 20, @"DNTimeConsumeDao-- getTimeByDate error");
    
    
    DNTimeConsumeModel *model =[[DNTimeConsumeDao shareInstance] getTimeConsumeByDate:dateStr];
     XCTAssertEqual(model.timeForCrying.integerValue, 20, @"DNTimeConsumeDao-- getTimeByDate error");
}

-(void)test3ForClearTime
{
    BOOL ret =[[DNTimeConsumeDao shareInstance] clearTimeByDate:dateStr];
    XCTAssertEqual(ret, YES, @"DNTimeConsumeDao-- clearTimeByDate error");
    
    NSString *currentTime = [[DNTimeConsumeDao shareInstance] getTimeByDate:dateStr type:ModuleType_Crying];
    XCTAssertEqual(currentTime.integerValue, 0, @"DNTimeConsumeDao-- getTimeByDate error");

}

@end
